import request from '@/utils/request'
import Qs from 'qs'

export function listOrder(query) {
  return request({
    url: '/order/list',
    method: 'get',
    params: query,
    paramsSerializer: function(params) {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
}

export function detailOrder(id) {
  return request({
    url: '/order/detail',
    method: 'get',
    params: { id }
  })
}

export function shipOrder(data) {
  return request({
    url: '/order/ship',
    method: 'post',
    data
  })
}

export function refundOrder(data) {
  return request({
    url: '/order/refund',
    method: 'post',
    data
  })
}

export function refused(query) {
  return request({
    url: 'http://www.hometasty.info/demo/odertui.php',
    method: 'get',
    params: query,
  })
}

export function atmReplay(data) {
  return request({
    url: '/order/updateAtmPayStatus',
    method: 'post',
    data
  })
}
export function getAtmPic(orderId) {
  return request({
    url: '/order/getAtmPic',
    method: 'get',
    params:{orderId:orderId}
  })
}
export function deleteOrder(data) {
  return request({
    url: '/order/delete',
    method: 'post',
    data
  })
}

export function replyComment(data) {
  return request({
    url: '/order/reply',
    method: 'post',
    data
  })
}

export function listChannel(id) {
  return request({
    url: '/order/channel',
    method: 'get'
  })
}
export function split(id) {
  return request({
    url: '/order/split',
    method: 'get',
    params: { id }
  })
}
// 订单完成
export function detok(orderSn) {
  return request({
    url: '/order/update',
    method: 'post',
    params: { orderSn }
  })
}
export function getUser(query) {
  return request({
    url: '/order/getUser',
    method: 'get',
    params: query,
    paramsSerializer: function(params) {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
}
export function getGoods(query) {
  return request({
    url: '/order/getGoods',
    method: 'get',
    params: query,
    paramsSerializer: function(params) {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
}

export function getAddress(userID) {
  return request({
    url: '/order/getAddress',
    method: 'get',
    params: { userID }
  })
}

export function pay(data) {
  return request({
    url: '/order/pay',
    method: 'post',
    data
  })
}

export function innsert(data) {
  return request({
    url: '/order/innsert',
    method: 'post',
    data
  })
}

export function updStateById(data) {
  return request({
    url: '/order/updStateById',
    method: 'post',
    data
  })
}
export function excelOrder(query) {
  return request({
    url: '/order/excel',
    method: 'get',
    params: query,
    paramsSerializer: function(params) {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
})
}
export function delivery(orderId,isFrozen) {
  return request({
    url: '/order/deliveryNote',
    method: 'get',
    params:{orderId:orderId,isFrozen:isFrozen}
  })
}
